home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #1 / Amiga Plus CD - 2000 - No. 1.iso / Tools / Dev / mamesrc / src / amiga / osd_cpu.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-12-03  |  2.9 KB  |  81 lines

  1. /*******************************************************************************
  2. *                                                                               *
  3. *    Define size independent data types and operations.                           *
  4. *                                                                               *
  5. *   The following types must be supported by all platforms:                       *
  6. *                                                                               *
  7. *    UINT8  - Unsigned 8-bit Integer        INT8  - Signed 8-bit integer           *
  8. *    UINT16 - Unsigned 16-bit Integer    INT16 - Signed 16-bit integer          *
  9. *    UINT32 - Unsigned 32-bit Integer    INT32 - Signed 32-bit integer          *
  10. *    UINT64 - Unsigned 64-bit Integer    INT64 - Signed 64-bit integer          *
  11. *                                                                               *
  12. *                                                                               *
  13. *   The macro names for the artithmatic operations are composed as follows:    *
  14. *                                                                               *
  15. *   XXX_R_A_B, where XXX - 3 letter operation code (ADD, SUB, etc.)               *
  16. *                     R   - The type    of the result                               *
  17. *                     A   - The type of operand 1                               *
  18. *                     B   - The type of operand 2 (if binary operation)           *
  19. *                                                                               *
  20. *                     Each type is one of: U8,8,U16,16,U32,32,U64,64               *
  21. *                                                                               *
  22. *******************************************************************************/
  23.  
  24.  
  25. #ifndef OSD_CPU_H
  26. #define OSD_CPU_H
  27.  
  28. #ifdef PPC
  29. #undef PPC /* Some cpu cores use structure members called PPC. */
  30. #endif
  31.  
  32. typedef unsigned char      UINT8;
  33. typedef unsigned short     UINT16;
  34. typedef unsigned int       UINT32;
  35. typedef unsigned long long UINT64;
  36. typedef signed char            INT8;
  37. typedef signed short           INT16;
  38. typedef signed int               INT32;
  39. typedef signed long long     INT64;
  40.  
  41. /* Combine to 32-bit integers into a 64-bit integer */
  42. #define COMBINE_64_32_32(A,B)     ((((UINT64)(A))<<32) | (B))
  43. #define COMBINE_U64_U32_U32(A,B)  COMBINE_64_32_32(A,B)
  44.  
  45. /* Return upper 32 bits of a 64-bit integer */
  46. #define HI32_32_64(A)          (((UINT64)(A)) >> 32)
  47. #define HI32_U32_U64(A)        HI32_32_64(A)
  48.  
  49. /* Return lower 32 bits of a 64-bit integer */
  50. #define LO32_32_64(A)          ((A) & 0xffffffff)
  51. #define LO32_U32_U64(A)        LO32_32_64(A)
  52.  
  53. #define DIV_64_64_32(A,B)       ((A)/(B))
  54. #define DIV_U64_U64_U32(A,B) ((A)/(UINT32)(B))
  55.  
  56. #define MOD_32_64_32(A,B)       ((A)%(B))
  57. #define MOD_U32_U64_U32(A,B) ((A)%(UINT32)(B))
  58.  
  59. #define MUL_64_32_32(A,B)       ((A)*(INT64)(B))
  60. #define MUL_U64_U32_U32(A,B) ((A)*(UINT64)(UINT32)(B))
  61.  
  62. /******************************************************************************
  63.  * Union of UINT8, UINT16 and UINT32 in native endianess of the target
  64.  * This is used to access bytes and words in a machine independent manner.
  65.  * The upper bytes h2 and h3 normally contain zero (16 bit CPU cores)
  66.  * thus PAIR.d can be used to pass arguments to the memory system
  67.  * which expects 'int' really.
  68.  ******************************************************************************/
  69. typedef union {
  70. #ifdef LSB_FIRST
  71.     struct { UINT8 l,h,h2,h3; } b;
  72.     struct { UINT16 l,h; } w;
  73. #else
  74.     struct { UINT8 h3,h2,h,l; } b;
  75.     struct { UINT16 h,l; } w;
  76. #endif
  77.     UINT32 d;
  78. }    PAIR;
  79.  
  80. #endif
  81.